/*
 * @Description: Api
 * @Author: xuyang 
 * @Date: 2019-06-09 09:07:12
 * @Last Modified by: XuYang
 * @Last Modified time: 2019-06-10 14:08:11
 */

import Api from './api';

const api = new Api({
  baseURI: getBaseURI(),
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  }
}); 

export function getBaseURI() {
  switch(process.env.NODE_ENV) {
    default: return 'http://118.31.110.78/api';// 'http://localhost:8553';
  }
}

export function AjaxServer(method, path,token, params = {}, data) {
  if(token)
    api.opts.headers.token = token;
  return api[method](path, { params, data });
}